package com.wangzhe.bean;

import com.wangzhe.utils.PropertiesUtils;
import lombok.Getter;

/**
 * @author 王哲
 * @ClassName Constants
 * @create 2023--六月--下午1:43
 * @Description 使用的一些常量
 * @Version V1.0
 */
@Getter
public class Constants {

    public static boolean IGNORE_TABLE_PREFIX;
    public static String DB_SUFFIX_BEAN_PARAM;
    public static String PACKAGE_EXAMPLE;
    public static String EXAMPLE_PATH;
    public static String PACKAGE_EXAMPLE_PATH;

    //vo包
    public static String PACKAGE_VO;
    public static String VO_PATH;
    public static String PACKAGE_VO_PATH;

    //获取生成POJO代码的路径
    public static String POJO_PACKAGE_PATH;
    public static String POJO_PATH;
    public static String POJO_BASE;
    public static String PATH_JAVA = "java";
    public static String PATH_RESOURCES = "resources";

    public static String PACKAGE_BASE;
    public static String ENTITY_POJO;
    public static String ENTITY_PARAM;

    //作者名称
    public static String AUTHOR_NAME;

    //需要忽略的属性
    public static String[] DB_IGNORE_BEAN_FIELD;
    public static String DB_IGNORE_BEAN_EXPRESSION;
    public static String DB_IGNORE_BEAN_IMPORT;

    //日期格式序列化与反序列化
    public static String DB_DATE_FORMAT_EXPRESSION;
    public static String DB_DATE_FORMAT_IMPORT;

    public static String DB_DATE_PARSE_EXPRESSION;
    public static String DB_DATE_PARSE_IMPORT;

    //基础工具类代码存放路径
    public static String UTILS_PACKAGE;
    public static String UTILS_PACKAGE_PATH;

    //枚举类代码存放路径
    public static String ENUM_PACKAGE;
    public static String ENUM_PACKAGE_PATH;

    //mapper代码存放路径
    public static String MAPPER_PACKAGE;
    public static String MAPPER_PACKAGE_PATH;
    //mapper的文件后缀
    public static String MAPPER_SUFFIX;

    //mapperxml代码存放路径
    public static String MAPPER_XML_PACKAGE;
    public static String MAPPER_XML_PACKAGE_PATH;
    //mapperxml的文件后缀
    public static String MAPPER_XML_SUFFIX;

    //service代码存放路径
    public static String PACKAGE_SERVICE;
    public static String PACKAGE_SERVICE_PATH;

    //serviceImpl代码存放路径
    public static String PACKAGE_SERVICE_IMPL;
    public static String PACKAGE_SERVICE_IMPL_PATH;

    //controller代码存放路径
    public static String PACKAGE_CONTROLLER;
    public static String PACKAGE_CONTROLLER_PATH;

    //异常类包名
    public static String PACKAGE_EXCEPTION;
    public static String PACKAGE_EXCEPTION_PATH;


    //参数模糊查询后缀
    public static String DB_SUFFIX_PARAM_LIKE;
    //参数日期起止
    public static String DB_SUFFIX_PARAM_START;
    public static String DB_SUFFIX_PARAM_END;

    static {
        IGNORE_TABLE_PREFIX = Boolean.parseBoolean(PropertiesUtils.getString("db.ignore.table.prefix"));
        DB_SUFFIX_BEAN_PARAM = PropertiesUtils.getString("db.suffix.bean.param");
        POJO_PACKAGE_PATH = PropertiesUtils.getString("pojo.package.name");
        PACKAGE_BASE = PropertiesUtils.getString("package.base");
        ENTITY_POJO = PropertiesUtils.getString("package.pojo");
        ENTITY_PARAM = PropertiesUtils.getString("package.param");
        PACKAGE_EXAMPLE = PropertiesUtils.getString("package.example");
        PACKAGE_VO = PropertiesUtils.getString("package.vo");
        //拼接包名
        POJO_BASE = PACKAGE_BASE+"."+ENTITY_POJO;
        EXAMPLE_PATH = PACKAGE_BASE+"."+PACKAGE_EXAMPLE;
        //拼接输出路径
        POJO_PATH = POJO_PACKAGE_PATH + PATH_JAVA + "/" +POJO_BASE.replace(".", "/");
        PACKAGE_EXAMPLE_PATH = POJO_PACKAGE_PATH + PATH_JAVA + "/" +EXAMPLE_PATH.replace(".", "/");

        VO_PATH = PACKAGE_BASE+"."+PACKAGE_VO;
        PACKAGE_VO_PATH = POJO_PACKAGE_PATH + PATH_JAVA + "/" +VO_PATH.replace(".", "/");
        //作者名称
        AUTHOR_NAME = PropertiesUtils.getString("author.name");


        //需要忽略的属性
        DB_IGNORE_BEAN_FIELD = PropertiesUtils.getString("db.ignore.bean.field").split(",");
        DB_IGNORE_BEAN_EXPRESSION = PropertiesUtils.getString("db.ignore.bean.expression");
        DB_IGNORE_BEAN_IMPORT = PropertiesUtils.getString("db.ignore.bean.import");

        //日期格式序列化与反序列化
        DB_DATE_FORMAT_EXPRESSION = PropertiesUtils.getString("db.date.format.expression");
        DB_DATE_FORMAT_IMPORT = PropertiesUtils.getString("db.date.format.import");

        DB_DATE_PARSE_EXPRESSION = PropertiesUtils.getString("db.date.parse.expression");
        DB_DATE_PARSE_IMPORT = PropertiesUtils.getString("db.date.parse.import");

        //基础工具类代码存放路径
        UTILS_PACKAGE = PACKAGE_BASE + "." +PropertiesUtils.getString("utils.package");
        UTILS_PACKAGE_PATH = POJO_PACKAGE_PATH + PATH_JAVA + "/" +UTILS_PACKAGE.replace(".", "/")+"/";

        //mapper代码存放路径
        MAPPER_PACKAGE = PACKAGE_BASE + "." +PropertiesUtils.getString("package.mapper");
        MAPPER_PACKAGE_PATH = POJO_PACKAGE_PATH + PATH_JAVA + "/" +MAPPER_PACKAGE.replace(".", "/")+"/";
        //mapper的文件后缀
        MAPPER_SUFFIX = PropertiesUtils.getString("package.mapper.suffix");

        //mapperxml代码存放路径
        MAPPER_XML_PACKAGE = PACKAGE_BASE + "." +PropertiesUtils.getString("package.mapper.xml");
        MAPPER_XML_PACKAGE_PATH = POJO_PACKAGE_PATH + PATH_RESOURCES + "/" +MAPPER_PACKAGE.replace(".", "/")+"/";
        //mapperxml的文件后缀
        MAPPER_XML_SUFFIX = PropertiesUtils.getString("package.mapper.xml.suffix");

        //service代码存放路径
        PACKAGE_SERVICE = PACKAGE_BASE + "." +PropertiesUtils.getString("package.service");
        PACKAGE_SERVICE_PATH = POJO_PACKAGE_PATH + PATH_JAVA + "/" +PACKAGE_SERVICE.replace(".", "/")+"/";
        //serviceImpl代码存放路径
        PACKAGE_SERVICE_IMPL = PACKAGE_SERVICE + "." +PropertiesUtils.getString("package.service.impl");
        PACKAGE_SERVICE_IMPL_PATH = POJO_PACKAGE_PATH + PATH_JAVA + "/" +PACKAGE_SERVICE_IMPL.replace(".", "/")+"/";
        //controller代码存放路径
        PACKAGE_CONTROLLER = PACKAGE_BASE + "." +PropertiesUtils.getString("package.controller");
        PACKAGE_CONTROLLER_PATH = POJO_PACKAGE_PATH + PATH_JAVA + "/" +PACKAGE_CONTROLLER.replace(".", "/")+"/";
        //Exception代码存放路径
        PACKAGE_EXCEPTION = PACKAGE_BASE + "." +PropertiesUtils.getString("package.exception");
        PACKAGE_EXCEPTION_PATH = POJO_PACKAGE_PATH + PATH_JAVA + "/" +PACKAGE_EXCEPTION.replace(".", "/")+"/";

        //枚举类代码存放路径
        ENUM_PACKAGE = PACKAGE_BASE + "." +PropertiesUtils.getString("enums.package");
        ENUM_PACKAGE_PATH = POJO_PACKAGE_PATH + PATH_JAVA + "/" +ENUM_PACKAGE.replace(".", "/")+"/";

        //参数模糊查询后缀
        DB_SUFFIX_PARAM_LIKE = PropertiesUtils.getString("db.suffix.bean.like");
        //参数日期起止
        DB_SUFFIX_PARAM_START = PropertiesUtils.getString("db.suffix.bean.date.start");
        DB_SUFFIX_PARAM_END = PropertiesUtils.getString("db.suffix.bean.date.end");
    }

    public static void main(String[] args) {
        System.out.println("PACKAGE_CONTROLLER = " + PACKAGE_CONTROLLER);
        System.out.println("PACKAGE_CONTROLLER_PATH = " + PACKAGE_CONTROLLER_PATH);

    }

    public static final String[] SQL_DATE_TIME_TYPES = {"datetime", "timestamp", "time", "year"};
    public static final String[] SQL_DATE_TYPES = {"date"};
    //可以转成Integer类型的
    public static final String[] SQL_INTEGER_TYPES = {"tinyint", "int", "integer"};
    //可以转成Double类型的
    public static final String[] SQL_DOUBLE_TYPES = {"double", "float", "decimal", "numeric"};
    //可以转成Long类型的
    public static final String[] SQL_LONG_TYPES = {"bigint"};
    //可以转成String类型的
    public static final String[] SQL_STRING_TYPES = {"char", "varchar", "tinytext", "text", "mediumtext", "longtext", "blob", "tinyblob", "mediumblob", "longblob"};
}
